package logic

import (
	"context"
	"good_srv/cache"

	"good_srv/good"
	"good_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CarListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCarListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CarListLogic {
	return &CarListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 购物车列表展示
func (l *CarListLogic) CarList(in *good.CarListRequest) (*good.CarListResponse, error) {
	// todo: add your logic here and delete this line
	list, err := cache.CarList(in.UserId, good.CarList{})
	if err != nil {
		logx.Error("购物车展示失败")
		return nil, err
	}

	return &good.CarListResponse{
		List: list,
	}, nil
}
